import { handleSearchLoading, handleSearchTime } from "@userList/search";
import {
  columns,
  searchList,
  tableActiveKey,
  defaultColumns,
  defaultSearchList,
} from "./store";
import { refreshTable } from ".";
const searchLoading = ref(false);
const resetLoading = ref(false);
export const searchConfig = () => {
  const defineSearch = {
    okText: getProxyT("base.query"),
    cancelText: getProxyT("base.reset"),
    searchLoading,
    resetLoading,
    refreshTableData: async (searchParams: any, type: any) => {
      handleSearchTime(
        ["start_created_at", "end_created_at"],
        searchParams,
        undefined,
        "start_end_created"
      );
      handleSearchTime(
        ["start_updated_at", "end_updated_at"],
        searchParams,
        undefined,
        "start_end_updated"
      );
      handleSearchLoading(true, type, defineSearch);
      await refreshTable(searchParams);
      handleSearchLoading(false, type, defineSearch);
    },
    tabsSlot: {
      activeKey: tableActiveKey,
      on: {
        change(tableActiveKey: any) {
          initObjAttr(columns, defaultColumns[tableActiveKey]);
          searchList.value = defaultSearchList[tableActiveKey];
          refreshTable();
        },
      },
      options: [
        {
          label: getProxyT("auth0"),
          value: 0,
        },
      ],
    },
    searchList,
  };
  return defineSearch;
};
